package com.wxy.customview;

import android.content.Context;
import android.support.annotation.Nullable;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.Toast;

public class ThumbView extends LinearLayout implements View.OnClickListener {

    private ThumbupView thumbupView;
    private CountView countView;

    public ThumbView(Context context) {
        this(context, null);
    }

    public ThumbView(Context context, @Nullable AttributeSet attrs) {
        this(context, attrs, -1);
    }

    public ThumbView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        setOrientation(HORIZONTAL);
        LayoutParams layoutParams0 = new LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
//        layoutParams0.gravity = Gravity.BOTTOM;

        thumbupView = new ThumbupView(context);
        thumbupView.setLayoutParams(layoutParams0);
        TuvPoint circlePoint = thumbupView.getCirclePoint();
        addView(thumbupView);
        countView = new CountView(context,1990);
        countView.setCount(1990);
        LayoutParams layoutParams = new LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
        layoutParams.leftMargin = 10;
        layoutParams.topMargin = (int) (circlePoint.y - countView.getContentHeight()/2);
//        layoutParams.gravity = Gravity.BOTTOM;
        countView.setLayoutParams(layoutParams);
        addView(countView);
        setOnClickListener(this);

    }

    @Override
    public boolean onInterceptTouchEvent(MotionEvent ev) {
        super.onInterceptTouchEvent(ev);
        return true;
    }

    @Override
    public void onClick(View view) {
        thumbupView.startAnim();
        countView.change();
    }
}
